﻿// Copyright (c) Vitaly Kamiansky. All rights reserved. 
// See License.txt in the project root.

using System;

namespace Property.Objects
{
    public abstract class DelegateProperty<T> : DecoupledProperty<T>
    {
        protected DelegateProperty(IReloaderPrototype<T> reloaderPrototype, Func<T, T> getValue, T defaultValue)
            : base(reloaderPrototype, defaultValue)
        {
            if (getValue == null) throw new ArgumentNullException("getValue");

            _GetValue = getValue;
        }

        //=//

        private readonly Func<T, T> _GetValue;

        protected override T GetValue()
        {
            return _GetValue(DebugValue);
        }
    }
}
